class Proposal < ActiveRecord::Base
  
  validates_presence_of :title, :description, :email, :status
  validates_format_of :email,
                      :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i,
                      :message => 'email must be valid'
                      
  has_many :documents
  has_many :reviews
  has_many :users, :through => :reviews
  has_many :notes
  
  def reviewsComplete?
    Review.find(:first, :conditions => { :proposal_id => :id, :status => "open"})
  end
  
  def longId
    created_at.year.to_s + "-" + created_at.month.to_s + "-" + id.to_s
  end
  
  def statusTag
    return "<div class=\"tag #{status}\"> #{status} </div>"
  end
    
end
